#include "analy/logic/ToolLogicCT.h"
#include <QTextCodec>
/* *********************************************************************************
列表切换，运行情况列表代码，并触发相关信号
闪退BUG：
QListWidgetItem *cur = BS_listWidget->item(index);
QString indexChar = cur->text();
由 currentRowChanged 信号触发，当前项目发生更改时，触发该信号，data_txtboxasb_facecut 函数运行，加载列表，而加载列表中包含列表clear函数，即先清除再加载，避免冗余的判断，data_reserve_loader 即为加载函数，
问题在于 清空列表后触发 currentRowChanged 信号， 该信号连接函数下存在获取iten的文本代码，列表已清空，但此时却获取不存在项的文本，从而引发致命错误，导致闪退

解决办法:
增加item是否为空判断

***死循环原因: 进入serial tool 工具时，触发定时任务，运行 basic_configration_init 函数， basic_configration_init 函数 执行
*** data_txtboxasb_facecut(DT_scview->objectName(), false);
*** data_serial_summaryconfig();
***而 data_serial_summaryconfig 函数中，完成 data_serial_Infoquery(); 查询后运行了 data_txtboxasb_facecut(QString ObjectName, bool whetherExec=true);函数，其默认值本为true的。
***运行 data_txtboxasb_facecut 函数后，触发 data_reserve_loader 最后执行 SRLP_DLRMV_QTIER定时任务，运行 data_listitem_echo 函数，选中选项，触发QListWidget 组件的选中信号，执行 data_listitem_slctev 函数
***data_listitem_slctev函数中，包含 data_serial_summaryconfig 函数，主要为了回显信息，但是 data_serial_summaryconfig 的 data_txtboxasb_facecut 不区分情况运行，因此导致进入循环中]
***循环周期为   serial tool -》 basic_configration_init << {data_txtboxasb_facecut, false}、{data_serial_summaryconfig, } -》 data_serial_summaryconfig << {data_txtboxasb_facecut, true} << data_reserve_loader << {data_listitem_echo,}
*** -》data_listitem_slctev << {data_serial_summaryconfig, false} << {data_txtboxasb_facecut, true};
********************************************************************************* */

ToolLogicCT::ToolLogicCT(QMap<QString, QMap<QString, QString>> &_RGLRLSMAP_,
                         QSqlDatabase *DB,
                         QMap<QString, QString> &_QSSMAP_)
    : ToolLogicRF(_RGLRLSMAP_, DB, _QSSMAP_){
    //#追加初始化日志类
    abstract_function_cchoice();
    diary("init successful", Diary::Debug)

//    QString path = "G:/BaiduSyncdisk/_和易充_/集中式和易充充电桩SE-ACCBC10-B001.3测试用例.xlsx";
//    QAxObject *excel = new QAxObject("Excel.Application");//excel应用程序
//    excel->dynamicCall("SetVisible(bool)", false); //true 表示操作文件时可见，false表示为不可见
//    QAxObject *workbooks = excel->querySubObject("WorkBooks");//所有excel文件
//    QAxObject *workbook = workbooks->querySubObject("Open(const QString&)", path);//按照路径获取文件
//    qDebug() << !workbook->isNull() << QFile(path).exists() << 515;
//    QAxObject * worksheets = workbook->querySubObject("WorkSheets");//获取文件的所有sheet页
//    QAxObject * worksheet = worksheets->querySubObject("Item(int)", 1);//获取文件sheet页
//    QAxObject * usedrange = worksheet->querySubObject("UsedRange");//有数据的矩形区域

////    //获取行数
////    QAxObject * rows = usedrange->querySubObject("Rows");
////    int nRows = rows->property("Count").toInt();
////    //获取列数
////    QAxObject * columns = usedrange->querySubObject("Columns");
////    int nColumns = columns->property("Count").toInt();

//    QVariant var = usedrange->dynamicCall("Value");
//    foreach(QVariant varRow,var.toList()){
//        foreach(QVariant var,varRow.toList()){
//            qDebug() << var.toString();
//        }
//    }
}



//# Analysis Edit Follow==============public
void ToolLogicCT::data_scfocus_follow(QString content){
    if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_SERIALTOOL)
    {
        SP_serialInfoEdit->appendPlainText(content);
    }

    else if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_ANALYTOOL)
    {
        DT_scdtEdit->appendPlainText(content);
    }
}

//# Edit Module Deputy Function
void ToolLogicCT::data_txtboxasb_triggered(NT::CST_BRIGHT_SPOT Type, QString objectName){
    switch (Type)
    {
        case NT::CUT_DEPUTYCLEAR:
            if (objectName == DT_scdtEditAsClear->objectName())
            {
                DT_scdtEdit->clear();
            }

            else if (objectName == SP_serialEditAsClear->objectName())
            {
                SP_serialInfoEdit->clear();
            }

            else if (objectName == DT_rsdtEditAsClear->objectName())
            {
                DT_rsdtEdit->clear();
            }
            break;

        case NT::CUT_DEPUTYUPDATE:
            if (objectName == SP_serialEditAsUpdater->objectName())
            {
                SP_serialInfoEdit->setBreakAwayFromFollow(true);
                SP_serialInfoEdit->insertPlainText("\n");
                MatchKeyWord->setTemproperyMight(); // rematching cursor for global text
            }
            break;

        case NT::CUT_DEPUTYDOWNLOAD:
            if (objectName == SP_serialEditAsDownLoad->objectName())
            {
                QString DateTimeFormat = "yyyy-MM-dd hhmmss";
                QString datet = QDateTime::currentDateTime().toString(DateTimeFormat);
                QString recordpath = (*__RLMAP__)["PATH"]["SERIALPATH"] + QString("/spdiary-%1.log").arg(datet);
                SCROPED_PATH_MAKE(recordpath)
                QTextCodec *Code = QTextCodec::codecForName("UTF-8");
                QByteArray Content = Code->fromUnicode(SP_serialInfoEdit->toPlainText());
                Reader::d_writer(recordpath, Content, QIODevice::WriteOnly);
                if (QFileInfo(recordpath).isFile())
                {
                    diary("serial record down->" + recordpath, Diary::Success)
                }
                else
                {
                    diary("serial record down error->" + recordpath + " is not exists", Diary::Error)
                }
            }
            break;

        default:
            diary("unvalid type", Diary::Error)
            break;
    }
}

//# Serial Error
void ToolLogicCT::data_serial_error(QSerialPort::SerialPortError error){
    QString errorText = SerialErrorMap[error];
    if (impact_str["SerialErrorText"] != errorText)
    {
        SP_serialInfoEdit->insertPlainText(errorText + "\n");
    }
    impact_str["SerialErrorText"] = errorText;
}

//# ListWidget Data Cut -> Connect/Command
void ToolLogicCT::data_txtboxasb_facecut(QString ObjectName, bool whetherExec){
    diary(QString("multi view objectname: %1").arg(ObjectName), Diary::Debug)
    if (whetherExec)
    {
        if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_ANALYTOOL)
        {
            if (ObjectName == DT_scview->objectName())
            {
                PBL_centraStackWidget->setCurrentWidget(DT_scdtEdit);
            }
            else if (ObjectName == DT_rsview->objectName())
            {
                PBL_centraStackWidget->setCurrentWidget(DT_rsdtEdit);
            }
        }

        else if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_SERIALTOOL)
        {
            if (ObjectName == DT_scview->objectName())
            {
                data_reserve_loader(NT::CUT_CONNECTLIST);
                if (SP_sralPort->isOpen())
                {
                    DT_exec->doconfigur_text("关闭串口");
                }
                else
                {
                    DT_exec->doconfigur_text("打开串口");
                }
                impact_ttype[RPLKEY.CUT_EXBUTCHANGE] = NT::CUT_CONNECTLIST;
            }

            else if (ObjectName == DT_rsview->objectName())
            {
                data_reserve_loader(NT::CUT_COMMANDLIST);
                DT_exec->doconfigur_text("发送");
                impact_ttype[RPLKEY.CUT_EXBUTCHANGE] = NT::CUT_COMMANDLIST;
            }

            else if (ObjectName == DT_hlview->objectName())
            {
                data_reserve_loader(NT::CUT_HLITEXTLIST);
                DT_exec->doconfigur_text("高亮设置列表");
                impact_ttype[RPLKEY.CUT_EXBUTCHANGE] = NT::CUT_HLITEXTLIST;
            }
        }

        else if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_QRCODETOOL)
        {
            if (ObjectName == DT_scview->objectName())
            {
                data_reserve_loader(NT::CUT_QRCODELIST);
                impact_ttype[RPLKEY.CUT_EXBUTCHANGE] = NT::CUT_CONNECTLIST;
            }
        }
    }

    if (ObjectName == DT_scview->objectName())
    {
        DT_scview->doconfigur_lock();
        DT_hlview->doconfigur_unlock();
        DT_rsview->doconfigur_unlock();
    }

    else if (ObjectName == DT_rsview->objectName())
    {
        DT_scview->doconfigur_unlock();
        DT_hlview->doconfigur_unlock();
        DT_rsview->doconfigur_lock();
    }

    else if (ObjectName == DT_hlview->objectName())
    {
        DT_scview->doconfigur_unlock();
        DT_rsview->doconfigur_unlock();
        DT_hlview->doconfigur_lock();
    }
    impact_str["MultiFaceObject"] = ObjectName;
}

// //# Load List Data
void ToolLogicCT::data_reserve_loader(NT::TOOL_VALIDCUT Type, bool isLoading){
    diary(QString("skip this, type: %1").arg(Type), Diary::Debug)
    if (isLoading) BS_listWidget->sclear();

    if (Type == NT::CUT_ANALYLIST)
    {
        foreach(QString func, AnalyFuncList)
        {
            if (BS_listWidget->findItems(func, Qt::MatchExactly).isEmpty())
            {
                if (isLoading) BS_listWidget->addItem(new QListWidgetItem(QIcon(":/PIXMAP/bench/analy-func.png"), func));
            }
        }
    }

    else if (Type == NT::CUT_COMMANDLIST)
    {
        if (!impact_str[RPLKEY.UPD_CNLIST_ITEMS].isEmpty() && !impact_stchar["ordernike"].isEmpty())
        {
            QStringList curNikeNameList = impact_stchar["ordernike"][impact_int[RPLKEY.UPD_CNLIST_ROW]].split("&&");
            if (!curNikeNameList.isEmpty() && isLoading)
            {
                foreach(QString cmd, curNikeNameList.filter(QRegularExpression(".+")))
                {
                    BS_listWidget->addItem(new QListWidgetItem(QIcon(":/PIXMAP/bench/command.png"), cmd));
                }
            }
        }
        diary("serial command successful  type: CUT_COMMANDLIST", Diary::Info)
    }

    else if (Type == NT::CUT_CONNECTLIST)
    {
        if (!impact_stchar["sp_name"].isEmpty() && isLoading)
        {
            foreach(QString cn, impact_stchar["sp_name"])
            {
                BS_listWidget->addItem(new QListWidgetItem(QIcon(":/PIXMAP/bench/connect.png"), cn));
            }
        }
        diary("serial connect successful  type: CUT_CONNECTLIST", Diary::Info)
    }

    else if (Type == NT::CUT_HLITEXTLIST)
    {
        //# 如果已经选择了连接。通过连接对应索引获取对应高亮数据
        if (!impact_str[RPLKEY.UPD_CNLIST_ITEMS].isEmpty() && !impact_stchar["highlight"].isEmpty())
        {
            impact_swtc["InfoLoading"] = isLoading;
            QStringList HLTextList = impact_stchar["highlight"][impact_int[RPLKEY.UPD_CNLIST_ROW]].split("&&");
            if (!HLTextList.filter(QRegularExpression(".+")).isEmpty())
            {
                foreach(QString hlText, HLTextList)
                {
                    // # simplified replace 为字符串引用，会该表原字符串
                    if (!QRegularExpression(".+").match(hlText).capturedTexts().isEmpty())
                    {
                        QColor bkColorT;
                        QColor frColorT;
                        QString newhlText = hlText;
                        QString simpleHlText = hlText.replace("->", " ").replace("|", ",");
                        impact_str[simpleHlText] = newhlText; //# 发生selectedEvent时作为映射字典获取原字符
                        QStringList hlTextList = newhlText.split("->");
                        if (!hlTextList.isEmpty() && hlTextList.count() >= 3)
                        {
                            QString hlText = hlTextList[0];
                            QString bkColor = hlTextList[1];
                            QString frColor = hlTextList[2];
                            QList<QVariant> hlbkColorList = data_serial_hlclparser(bkColor, NULL, NULL, 1);
                            QList<QVariant> hlfrColorList = data_serial_hlclparser(frColor, NULL, NULL, 1);
                            if (!hlbkColorList.isEmpty() && !hlfrColorList.isEmpty())
                            {
                                bkColorT = QColor(hlbkColorList[0].toUInt(),
                                                  hlbkColorList[1].toUInt(),
                                                  hlbkColorList[2].toUInt());
                                frColorT = QColor(hlfrColorList[0].toUInt(),
                                                  hlfrColorList[1].toUInt(),
                                                  hlfrColorList[2].toUInt());
                                SyntaxHLight->appendHignLight(hlText,
                                                              bkColorT,
                                                              frColorT);

                            }
                        }
                        if (isLoading)
                        {
                            QListWidgetItem *item = new QListWidgetItem(simpleHlText.rightJustified(simpleHlText.size() + 3, ' '));
                            QList<QColor> ToolbarColor {bkColorT, frColorT};
                            Nwidget *colorWidget = new Nwidget();
                            colorWidget->doconfigur_direction(NT::ORIEN_VERTICAL);
                            colorWidget->doconfigur_secolor(ToolbarColor);
                            BS_listWidget->addItem(item);
                            BS_listWidget->setItemWidget(item, colorWidget);
                            BS_listWidget->itemWidget(item)->setMaximumWidth(22);
                        }
                    }
                }
            }
        }diary("serial high light load successful  type: CUT_HLITEXTLIST", Diary::Info)
    }

    else if (Type == NT::CUT_QRCODELIST)
    {
        QStringList curQRTextList = impact_stchar["alias"];
        if (!curQRTextList.filter(QRegularExpression(".+")).isEmpty())
        {
            foreach(QString qrText, curQRTextList)
            {

                if (isLoading) BS_listWidget->addItem(new QListWidgetItem(QIcon(":/PIXMAP/bench/qrcode.png"), qrText));
            }
        }
        diary("qrcode infomation load successful  type: CUT_QRCODELIST", Diary::Info)
    }

    if (isLoading) SRLP_DLRMV_QTIER.start();
}

//# Serial Connect/Command Remove
void ToolLogicCT::data_list_remove(){
    diary("skip this", Diary::Debug)
    QString removeSql;
    diary("listwidget itemtake begin", Diary::Warning)
    if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
    {
        QString NikeNameArg;
        QStringList itemTextList = impact_str[RPLKEY.UPD_CNLIST_ITEMS].split("&&");
        if(itemTextList.size() == 1)
        {
            NikeNameArg = QString("('%1')").arg(itemTextList.first());
        }
        else
        {
            QStringList i;
            foreach(QString item, itemTextList) i.append(QString("'%1'").arg(item));
            NikeNameArg = QString("(%1)").arg(i.join(","));
        }
        removeSql = QString("DELETE FROM serial WHERE sp_name in %1").arg(NikeNameArg);
        diary("remove sql is ready and of CUT_CONNECTLIST type", Diary::Warning)
    }

    else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_COMMANDLIST)
    {
        QStringList commandCodeList = impact_stchar["ordercode"][impact_int[RPLKEY.UPD_CNLIST_ROW]].split("&&");
        QStringList commandNikeList = impact_stchar["ordernike"][impact_int[RPLKEY.UPD_CNLIST_ROW]].split("&&");
        QString NikeName = impact_stchar["sp_name"][impact_int[RPLKEY.UPD_CNLIST_ROW]];
        QStringList itemTextList = impact_str[RPLKEY.UPD_ODLIST_ITEMS].split("&&");
        foreach (int row, impact_stint[RPLKEY.UPD_ODLIST_ROWS])
        {
            commandCodeList.replace(row, "");
            commandNikeList.replace(row, "");
        }
        QString commandCode = commandCodeList.filter(QRegularExpression(".+")).join("&&");
        QString commandNike = commandNikeList.filter(QRegularExpression(".+")).join("&&");
        removeSql = QString("UPDATE serial SET ordercode='%1', ordernike='%2' WHERE sp_name='%3'").arg(
                    commandCode, commandNike, NikeName);
        diary("remove sql is ready and of CUT_COMMANDLIST type", Diary::Warning)
    }

    else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_HLITEXTLIST)
    {
        QStringList highLightList = impact_stchar["highlight"][impact_int[RPLKEY.UPD_CNLIST_ROW]].split("&&");
        QString NikeName = impact_stchar["sp_name"][impact_int[RPLKEY.UPD_CNLIST_ROW]];
        QStringList retainList;
        foreach (QString data, highLightList)
        {
            if (!impact_stint[RPLKEY.UPD_HLLIST_ROWS].contains(highLightList.indexOf(data)))
            {
                retainList.append(data);
            }
            else
            {
                //# 删除高亮key值，data为一段色素数据，由->隔开，分割后取第一个数据即为文本数据
                SyntaxHLight->removeHighLightKey(data.split("->").first());
            }
        }
        QString highLight = retainList.filter(QRegularExpression(".+")).join("&&");
        removeSql = QString("UPDATE serial SET highlight='%1' WHERE sp_name='%3'").arg(
                    highLight, NikeName);
        diary("remove sql is ready and of CUT_HLITEXTLIST type", Diary::Warning)
    }

    else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_QRCODELIST)
    {
        QStringList qrcodeIDList = impact_stchar["ID"];
        QList<QString> renmoveList;
        foreach (uint row, impact_stint[RPLKEY.UPD_QRLIST_ROWS])
        {
            renmoveList.append(impact_stchar["id"][row]);
        }
        removeSql = QString("DELETE FROM qrcode WHERE id in (%1)").arg(renmoveList.join(","));
        diary("remove sql is ready and of CUT_QRCODELIST type", Diary::Warning)
    }


    if (Query->exec(removeSql))
    {
        if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
        {
            data_serial_Infoquery();
            data_reserve_loader(NT::CUT_CONNECTLIST);
        }

        else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_COMMANDLIST)
        {
            data_serial_Infoquery();
            data_reserve_loader(NT::CUT_COMMANDLIST);
        }

        else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_HLITEXTLIST)
        {
            data_serial_Infoquery();
            data_reserve_loader(NT::CUT_HLITEXTLIST);
        }

        else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_QRCODELIST)
        {
            data_qrcode_Infoquery();
            data_reserve_loader(NT::CUT_QRCODELIST);
        }
        diary(QString("listWidget itemtake end, type: %1").arg(impact_ttype[RPLKEY.CUT_EXBUTCHANGE]), Diary::Success)
    }
    else
    {
        diary(QString("listWidget itemtake error: %1").arg(Query->lastError().text()), Diary::Error)
    }
}

//# History Selection Delay Visible
void ToolLogicCT::data_listitem_echo(){
    diary("skip this", Diary::Debug)
    QStringList selectedItemTextList;
    if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
    {
        selectedItemTextList = impact_str[RPLKEY.UPD_CNLIST_ITEMS].split("&&");
    }

    else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_COMMANDLIST)
    {
        selectedItemTextList = impact_str[RPLKEY.UPD_ODLIST_ITEMS].split("&&");
    }

    else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_HLITEXTLIST)
    {
        if (!impact_stint[RPLKEY.UPD_HLLIST_ROWS].isEmpty())
        {
            foreach(int row, impact_stint[RPLKEY.UPD_HLLIST_ROWS])
            {
                //# 排除空列表得情况
                if (BS_listWidget->count() != 0 && BS_listWidget->count() >= row + 1)
                    selectedItemTextList.append(BS_listWidget->item(row)->text());
            }
        }
    }

    else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_QRCODELIST)
    {
        if (!impact_stint[RPLKEY.UPD_QRLIST_ROWS].isEmpty())
        {
            foreach(int row, impact_stint[RPLKEY.UPD_QRLIST_ROWS])
            {
                //# 排除空列表得情况
                if (BS_listWidget->count() != 0 && BS_listWidget->count() >= row + 1)
                    selectedItemTextList.append(BS_listWidget->item(row)->text());
            }
        }
    }

    foreach(QString item, selectedItemTextList)
    {
        QList<QListWidgetItem *> selectedItemsList = BS_listWidget->findItems(item, Qt::MatchExactly);
        if (!selectedItemsList.isEmpty())
        {
            foreach(QListWidgetItem *item, selectedItemsList)
            {
                if (!item->isSelected()) item->setSelected(true);
            }
        }
    }

    diary("serial history option recover", Diary::Info)
}

//# Query List Data Of Qrcode
void ToolLogicCT::basic_configration_init(){
    diary("delay task running", Diary::Debug)
    QRegularExpression dreg("\\d+");
    QString _width = (*__RLMAP__)["TOOL"]["WindownGeometryW"];
    QString _height = (*__RLMAP__)["TOOL"]["WindownGeometryH"];
    if (definfc.Max(dreg.match(_width).capturedTexts()).toInt() == _width.size() &&
        definfc.Max(dreg.match(_height).capturedTexts()).toInt() == _height.size())
    {
        int width = _width.toUInt();
        int height = _height.toUInt();
        if (!isVisible())
        {
            (width && height) ? resize(width, height) : resize(1020, 630);
            setVisible(true);
        }
        diary("global win setVisible->true", Diary::Debug)
    }

    /* path box default folder check */
    QString CommonlyFolder = (*__RLMAP__)["TOOL"]["CommonlyFolder"];
    QFileInfo commonlyInfo = QFileInfo(CommonlyFolder);
    if (QFile(CommonlyFolder).exists())
    {
        if (commonlyInfo.isDir()){
            impact_str["mdrs-follow-directory"] = CommonlyFolder;
        } else {
            impact_str["mdrs-follow-directory"] = commonlyInfo.filePath();
        }
    }
    else
    {
        if (CommonlyFolder.toLower() == "follow")
        {
            impact_str["mdrs-follow-directory"] = CommonlyFolder;
        }
        else
        {
            impact_str["mdrs-follow-directory"] = "./";
        }
    }

    if (impact_ttype[RPLKEY.CUT_FUNCNAME]  == NT::CUT_ANALYTOOL &&
        impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_ANALYLIST)
    {
        data_reserve_loader(NT::CUT_ANALYLIST, true);
        data_txtboxasb_facecut(DT_scview->objectName(), false);
    }

    else if (impact_ttype[RPLKEY.CUT_FUNCNAME]  == NT::CUT_QRCODETOOL &&
             impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_QRCODELIST)
    {
        //#==========默认二维码路径参数获取
        QString QRcodePath = (*__RLMAP__)["CMR"]["QRcodeSavePath"];
        QFileInfo info = QFileInfo(QRcodePath);
        if (QFile(QRcodePath).exists())
        {
            if (info.isFile())
            {
                impact_str.insert("QRcodePath", info.canonicalPath());
            }

            else if (info.isDir())
            {
                impact_str.insert("QRcodePath", QRcodePath);
            }
        }

        else
        {
            impact_str.insert("QRcodePath", (*__RLMAP__)["PATH"]["QRCODEPATH"]);
        }
        //#=============二维码边框线条尺寸
        QString QRcodeBorderXP = (*__RLMAP__)["CMR"]["QrcodeBorderXP"];
        QString QRcodePointXP = (*__RLMAP__)["CMR"]["QrcodeSizeRtXP"];
        if (definfc.isInt(QRcodeBorderXP))
        {
            impact_int["QRcodeBorderXP"] = QRcodeBorderXP.toUInt();
        }
        else
        {
            impact_int["QRcodeBorderXP"] = 4;
        }
        if (definfc.isInt(QRcodePointXP))
        {
            impact_int["QrcodeSizeRtXP"] = QRcodePointXP.toUInt();
        }
        else
        {
            impact_int["QrcodeSizeRtXP"] = 2;
        }

        //#=============二维码格式参数
        QString formatT = (*__RLMAP__)["CMR"]["ConstomMakeCharE"];
        QString formatE = (*__RLMAP__)["CMR"]["ConstomMakeChar"];
        QString getReadyT = "{'cameraID':'%1', 'P':'%2'}";
        QString getReadyE = "{'cameraID':'%1'}";
        data_qrcode_formatbeautify(formatT);
        data_qrcode_formatbeautify(formatE);
        if (formatE.isEmpty())
        {
            impact_str["QRformatE"] = getReadyE;
        }
        else
        {
            impact_str["QRformatE"] = formatE;
        }

        if (formatT.isEmpty())
        {
            impact_str["QRformatT"] = getReadyT;
        }
        else
        {
            impact_str["QRformatT"] = formatT;
        }

        //#=============二维码颜色参数
        if (QColor((*__RLMAP__)["CMR"]["QrcodeBackColor"]).isValid() &&
            QColor((*__RLMAP__)["CMR"]["QrcodeForeColor"]).isValid())
        {
            impact_str["QRbackColor"] = (*__RLMAP__)["CMR"]["QrcodeBackColor"];
            impact_str["QRforeColor"] = (*__RLMAP__)["CMR"]["QrcodeForeColor"];
        }
        else
        {
            impact_str["QRbackColor"] = "IndianRed";
            impact_str["QRforeColor"] = "white";
        }
        data_txtboxasb_facecut(DT_scview->objectName(), false);
        QR_keysEdit->setVisible(false); //# 默认非相机模式，不显示key文本框
        data_qrcode_Infoquery();
        data_reserve_loader(NT::CUT_QRCODELIST);
    }

    else if (impact_ttype[RPLKEY.CUT_FUNCNAME]  == NT::CUT_SERIALTOOL &&
             impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
    {
        data_serial_Infoquery();
        data_txtboxasb_facecut(DT_scview->objectName(), true);
        data_serial_summaryconfig();
        diary(data_serialport_loopc(), Diary::Debug)
    }
}

//# SyncGet Serial Info
QString ToolLogicCT::data_serialport_loopc(){
    QList<QSerialPortInfo> portInfoList = QSerialPortInfo::availablePorts();
    QStringList hintLogList;
    QList<QAction *> menuActionList;
    QString hintLogChar;
    QString swapLineChar;
    QFont spFont(font());
    QString emptyhintPort = NULL;
    if (portInfoList.isEmpty())
    {
        hintLogChar = emptyhintPort;
        SP_usbportBut->setEnabled(false);
    }
    else
    {
        foreach(QSerialPortInfo port, portInfoList)
        {
            QString SerialInfo = port.description() + " " + port.portName();
            hintLogList.append(SerialInfo);
            impact_str[SerialInfo] = port.portName();
            menuActionList.append(new QAction(SerialInfo, SP_usbPortMenu));
        }
        if (hintLogList.isEmpty())
        {
            SP_usbportBut->setEnabled(false);
            hintLogChar = emptyhintPort;
        }
        else
        {
            SP_usbportBut->setEnabled(true);
            hintLogChar = definfc.rectInfoProduction('|', '=', '|', '=', ' ', 2, hintLogList, spFont);
            swapLineChar = hintLogChar;
            swapLineChar.remove("\t");
            hintLogChar = "端口可用:" + swapLineChar;
        }
    }

    //# 如果获取到的端口与历史端口不一致或无端口数据，更新菜单选项，打印端口信息
    definfc.compareList(menuActionList, SPActionList);
    //# 如果端口为空并且提示字符与历史提示字符不一致(有到无或无到有)，或有但异，则执行以下代码
    if ((hintLogChar == emptyhintPort &&
        impact_str["SerialLastHint"] != hintLogChar) ||
        !definfc.compareList(menuActionList, SPActionList))
    {
        if (!SPActionList.isEmpty()) {foreach (QAction *ac, SPActionList) {delete ac;}};
        SPActionList.swap(menuActionList);
        menuActionList.clear();
        SP_usbPortMenu->clear();
        SP_usbPortMenu->addActions(SPActionList);
        SP_serialInfoEdit->insertPlainText(hintLogChar);
        impact_str["SerialLastHint"] = hintLogChar;
    }
    return hintLogChar;
}

//# Serial Edit Follow
void ToolLogicCT::data_txtbox_focusfollow(){
    QString DateTimeFormat = "hh:mm:ss";
    QString FORMATDATE = QDateTime::currentDateTime().toString(DateTimeFormat);
    QString TimeStemp = QString("[%1]%2");
    QString readContent = SP_sralPort->readAll();
    QTextCodec *textCode = QTextCodec::codecForName("TSCII");
    //#优化字符拼接断续的问题
    if (!readContent.simplified().isEmpty())
    {
        //# 字符中间换行标识 isCentraWordSwap 与末尾换行标识 isEndWordSwap
        bool isCentraWordSwap = QRegularExpression("\r|\n").match(readContent.trimmed()).capturedTexts().isEmpty();
        bool isEndWordSwap = QRegularExpression("[\n|\r]$").match(readContent).capturedTexts().isEmpty();
        //# 如果字符串中间不存在换行操作
        if (isCentraWordSwap)
        {
            //#并且上一个字符串不存在末尾换行。则正常拼接字符串，保证其完整性
            if (impact_swtc["isEndWordSwap"])
            {
                SP_serialInfoEdit->insertPlainText(textCode->fromUnicode(readContent));
            }
            //#如果上一个字符串存在末尾换行，即当前行为新的起始行，则添加时间戳
            else
            {
                SP_serialInfoEdit->insertPlainText(TimeStemp.arg(FORMATDATE, "  ") + textCode->fromUnicode(readContent));
            }
        }
        //#如果字符串存在中间换行操作，即该字符串为较长字符串
        else
        {
            //#如果字符串不存在末尾换行 并且 isEndWordSwap KEY 存在于字典中，即已经存在过赋值操作，则正常拼接字符串，保证其完整性
            if (isEndWordSwap && impact_swtc.contains("isEndWordSwap"))
            {
                SP_serialInfoEdit->insertPlainText(textCode->fromUnicode(readContent));
            }
            //#如果存在末尾换行
            else
            {
                //#如果上一个字符串不存在末尾换行，则正常拼接字符串，保证其完整性
                if (impact_swtc["isEndWordSwap"])
                {
                    SP_serialInfoEdit->insertPlainText(textCode->fromUnicode(readContent));
                }
                //#否则添加时间戳明显和标识，并在末尾增加换行以方便区分较长字符串
                else
                {
                    SP_serialInfoEdit->insertPlainText(TimeStemp.arg(FORMATDATE, "\n") + textCode->fromUnicode(readContent) + "\n");
                }
            }
        }
        //# 如果文本不为空，再进行末尾换行标识的字典赋值，否则为空一般为\R\N字符，影响实际判断，导致结果不正确
        if (!readContent.simplified().isEmpty()) impact_swtc["isEndWordSwap"] = isEndWordSwap;
    }
}

//# Scroll To TextCursor
void ToolLogicCT::data_txtbox_passivityfollow(QTextCursor cursor){
    cursor.movePosition(QTextCursor::StartOfLine);
    SP_serialInfoEdit->setTextCursor(cursor);
}

//# Connect Configular Send
void ToolLogicCT::data_serial_detailconfig(QString Actext, SerialAttribute Attribute, bool isConfiguration){
    if (isConfiguration)
    {
        diary(Actext + " attribute type: " + QString::number(Attribute) + "configuration", Diary::Debug)
    }

    else
    {
        diary(Actext + " attribute type: " + QString::number(Attribute) + "list info echo", Diary::Debug)
    }

    switch (Attribute) {
        case BaudRate:
            if (Actext == "115200")
            {
                SP_sralPort->setBaudRate(QSerialPort::Baud115200);
            }
            else if (Actext == "57600")
            {
                if (isConfiguration) SP_sralPort->setBaudRate(QSerialPort::Baud57600);
            }
            else if (Actext == "38400")
            {
                if (isConfiguration) SP_sralPort->setBaudRate(QSerialPort::Baud38400);
            }
            else if (Actext == "19200")
            {
                if (isConfiguration) SP_sralPort->setBaudRate(QSerialPort::Baud19200);
            }
            else if (Actext == "9600")
            {
                if (isConfiguration) SP_sralPort->setBaudRate(QSerialPort::Baud9600);
            }
            else if (Actext == "4800")
            {
                if (isConfiguration) SP_sralPort->setBaudRate(QSerialPort::Baud4800);
            }
            else if (Actext == "2400")
            {
                if (isConfiguration) SP_sralPort->setBaudRate(QSerialPort::Baud2400);
            }
            else
            {
                if (isConfiguration) SP_sralPort->setBaudRate(QSerialPort::Baud1200);

            }
            impact_str["SQL_SRLP_BAUD"] = QString("BaudRate = '%1'").arg(Actext);
            if (isConfiguration)
            {
                SP_baudrateBut->setText(Actext);
            }
            else
            {
                SPitem_viewBaudV->doconfigur_text(Actext);
            }
            break;

        case DtPlace:
            if (Actext == "bits 5")
            {
                if (isConfiguration) SP_sralPort->setDataBits(QSerialPort::Data5);
            }
            else if (Actext == "bits 6")
            {
                if (isConfiguration) SP_sralPort->setDataBits(QSerialPort::Data6);
            }
            else if (Actext == "bits 7")
            {
                if (isConfiguration) SP_sralPort->setDataBits(QSerialPort::Data7);
            }
            else
            {
                if (isConfiguration) SP_sralPort->setDataBits(QSerialPort::Data8);
            }
            impact_str["SQL_SRLP_DTPL"] = QString("dataplace = '%1'").arg(Actext);
            if (isConfiguration)
            {
                SP_dtplaceBut->setText(Actext);
            }
            else
            {
                SPitem_viewdataplV->doconfigur_text(Actext);
            }
            break;

        case StPlace:
            if (Actext == "bits 1")
            {
                if (isConfiguration) SP_sralPort->setStopBits(QSerialPort::OneStop);
            }
            else if (Actext == "bits 1.5")
            {
                if (isConfiguration) SP_sralPort->setStopBits(QSerialPort::OneAndHalfStop);
            }
            else
            {
                if (isConfiguration) SP_sralPort->setStopBits(QSerialPort::TwoStop);
            }
            impact_str["SQL_SRLP_STPL"] = QString("stopplace = '%1'").arg(Actext);
            if (isConfiguration)
            {
                SP_stplaceBut->setText(Actext);
            }
            else
            {
                SPitem_viewStopplV->doconfigur_text(Actext);
            }
            break;

        case Scontrol:
            if (Actext == "硬件控制")
            {
                if (isConfiguration) SP_sralPort->setFlowControl(QSerialPort::HardwareControl);
            }
            else if (Actext == "软件控制")
            {
                if (isConfiguration) SP_sralPort->setFlowControl(QSerialPort::SoftwareControl);
            }
            else
            {
                if (isConfiguration) SP_sralPort->setFlowControl(QSerialPort::NoFlowControl);
            }
            impact_str["SQL_SRLP_SCTL"] = QString("scontrol = '%1'").arg(Actext);
            if (isConfiguration)
            {
                SP_scontrolBut->setText(Actext);
            }
            else
            {
                SPitem_viewStreamV->doconfigur_text(Actext);
            }
            break;

       case CheckPlace:
            if (Actext == "奇校验")
            {
                if (isConfiguration) SP_sralPort->setParity(QSerialPort::OddParity);
            }
            else if (Actext == "偶校验")
            {
                if (isConfiguration) SP_sralPort->setParity(QSerialPort::EvenParity);
            }
            else
            {
                if (isConfiguration) SP_sralPort->setParity(QSerialPort::NoParity);
            }
            impact_str["SQL_SRLP_PRTY"] = QString("checkplace = '%1'").arg(Actext);
            if (isConfiguration)
            {
                SP_ckplaceBut->setText(Actext);
            }
            else
            {
                SPitem_viewCheckV->doconfigur_text(Actext);
            }
            break;

        case SerialPort:
            QString portName;
            impact_str[Actext].isEmpty() ? portName = "Empty" : portName = impact_str[Actext];
            QFontMetrics portNameMetrics(SP_usbPortMenu->font());
            int acWidth = portNameMetrics.horizontalAdvance(Actext);
            int butWidth = SP_usbportBut->width();
            diary(QString("ac-w: %1 bt-w: %2 pr-n: %3").arg(QString::number(acWidth),
                                                                    QString::number(butWidth),
                                                                    portName), Diary::Info)
            if (acWidth <= butWidth)
            {
                if (isConfiguration)
                {
                    SP_usbportBut->setText(Actext);
                }
                else
                {
                    SPitem_viewNikeV->doconfigur_text(Actext);
                }
            }
            else
            {
                if (isConfiguration)
                {
                    SP_usbportBut->setText(portName);
                }
                else
                {
                    SPitem_viewNikeV->doconfigur_text(portName);
                }
            }
            QSerialPortInfo SP_sralPortInfo(portName);
            if (portName != SP_sralPort->portName() && isConfiguration) data_listitem_unslctev();
            if (isConfiguration)
            {
                if (SP_sralPort->isOpen())
                {
                    SP_sralPort->close();
                    SP_sralPort->setPort(SP_sralPortInfo);
                    data_serial_connectbranch(NT::CUT_SERIALCONNECT);
                } else SP_sralPort->setPort(SP_sralPortInfo);
            }
            impact_str["SQL_SRLP_PORT"] = QString("portname = '%1'").arg(Actext);
            break;
    }
}

//# Connect Default Data Configular
void ToolLogicCT::data_serial_summaryconfig(bool isConfiguration, QString NikeNameArg){
    diary(QString("skip this, isconfiguration:%1 nikenamearg:%2").arg(
                  QString::number(isConfiguration), NikeNameArg), Diary::Debug)
    QString SQL_portName=NULL;
    QString SQL_baudRate=NULL;
    QString SQL_dataPlace=NULL;
    QString SQL_stopPlace=NULL;
    QString SQL_checkPlace=NULL;
    QString SQL_sControl=NULL;
    QString SQL_NikeName=NULL;
    //# 没有指定别名时，依据已应用的数据进行加载，当不存在已应用的数据时，变量初始赋值NULL会触发默认值
    if (NikeNameArg.isEmpty())
    {
        if (!impact_stchar["apply"].isEmpty() &&
            impact_stchar["apply"].contains(QString::number(true)))
        {
            impact_int["serialSqlIndex"] = impact_stchar["apply"].indexOf(QString::number(true));
            if (!impact_stchar["portname"][impact_int["serialSqlIndex"]].isEmpty())
            {
                SQL_NikeName = impact_stchar["sp_name"][impact_int["serialSqlIndex"]];
                SQL_portName = impact_stchar["portname"][impact_int["serialSqlIndex"]];
                SQL_baudRate = impact_stchar["baudrate"][impact_int["serialSqlIndex"]];
                SQL_dataPlace = impact_stchar["dataplace"][impact_int["serialSqlIndex"]];
                SQL_stopPlace = impact_stchar["stopplace"][impact_int["serialSqlIndex"]];
                SQL_checkPlace = impact_stchar["checkplace"][impact_int["serialSqlIndex"]];
                SQL_sControl = impact_stchar["scontrol"][impact_int["serialSqlIndex"]];
                if (impact_int["serialSqlIndex"] < BS_listWidget->count())
                {
                    QListWidgetItem *expectItem = BS_listWidget->item(impact_int["serialSqlIndex"]);
                    if (expectItem) expectItem->setSelected(true);
                    diary(QString("serialinfo apply indexof %1, allocation to give listwidget").arg(impact_int["serialSqlIndex"]), Diary::Debug)
                }
            }
        }
        else
        {
            if (BS_listWidget->count() > 0) BS_listWidget->item(0)->setSelected(true);
            diary("unapply, using listwidget option for one", Diary::Debug)
        }
    }

    else
    {
        if (!impact_stchar["portname"].isEmpty() &&
            !NikeNameArg.isEmpty() &&
            impact_stchar["portname"].contains(NikeNameArg))
        {
            int changeIndex = impact_stchar["portname"].indexOf(NikeNameArg);
            SQL_NikeName = impact_stchar["sp_name"][changeIndex];
            SQL_portName = impact_stchar["portname"][changeIndex];
            SQL_baudRate = impact_stchar["baudrate"][changeIndex];
            SQL_dataPlace = impact_stchar["dataplace"][changeIndex];
            SQL_stopPlace = impact_stchar["stopplace"][changeIndex];
            SQL_checkPlace = impact_stchar["checkplace"][changeIndex];
            SQL_sControl = impact_stchar["scontrol"][changeIndex];
            diary("sqlite customize spinfo values allocation", Diary::Info)
        } else diary("sqlite customize spinfo values is empty", Diary::Info)
    }

    if (SQL_portName.isEmpty() && !SPActionList.isEmpty())
    {
        data_serial_detailconfig(SPActionList.first()->text(), SerialPort, isConfiguration);
    }
    else
    {
        data_serial_detailconfig(SQL_portName, SerialPort, isConfiguration);
    }

    if (SQL_baudRate.isEmpty())
    {
        data_serial_detailconfig(AS_baudr115200->text(), BaudRate, isConfiguration);
    }
    else
    {
        data_serial_detailconfig(SQL_baudRate, BaudRate, isConfiguration);
    }

    if (SQL_dataPlace.isEmpty())
    {
        data_serial_detailconfig(AS_dtbitsEight->text(), DtPlace, isConfiguration);
    }
    else
    {
        data_serial_detailconfig(SQL_dataPlace, DtPlace, isConfiguration);
    }

    if (SQL_stopPlace.isEmpty())
    {
        data_serial_detailconfig(AS_stbitsOne->text(), StPlace, isConfiguration);
    }
    else
    {
        data_serial_detailconfig(SQL_stopPlace, StPlace, isConfiguration);
    }

    if (SQL_checkPlace.isEmpty())
    {
        data_serial_detailconfig(AS_unParity->text(), CheckPlace, isConfiguration);
    }
    else
    {
        data_serial_detailconfig(SQL_checkPlace, CheckPlace, isConfiguration);
    }

    if (SQL_sControl.isEmpty())
    {
        data_serial_detailconfig(AS_unControl->text(), Scontrol, isConfiguration);
    }
    else
    {
        data_serial_detailconfig(SQL_sControl, Scontrol, isConfiguration);
    }
    diary("serial defualt option config", Diary::Info)
}

//# Connect Save And Update And Connect
void ToolLogicCT::data_serial_connectbranch(NT::TOOL_VALIDCUT Type){
    diary("skip this", Diary::Debug)
    QStringList serialInsertList;
    QString serialConnectSql;
    QStringList serialMapkeyList = impact_str.keys();
    QStringList serialKeyList = serialMapkeyList.filter("SQL_SRLP");
    QMap<QString, QList<QString>> serialInfoMap = definfc.SuperQuery(DATABASE, "serial");
    QString portName = impact_str["SQL_SRLP_PORT"].split("=").last().simplified().replace("\'", "");
    QString NikeName = impact_str[RPLKEY.UPD_CNLIST_ITEMS].split("&&").last();
    if (Type == NT::CUT_SERIALUPDATE && !impact_str[RPLKEY.UPD_CNLIST_ITEMS].isEmpty())
    {
        if (serialInfoMap["sp_name"].contains(NikeName))
        {
            foreach(QString key, serialKeyList) serialInsertList.append(impact_str[key]);
            serialConnectSql = QString("UPDATE serial SET %1 WHERE sp_name='%2'").arg(serialInsertList.join(","), NikeName);
            diary(QString("sql statement update finish, this: \n\t\t%1").arg(serialConnectSql), Diary::Debug)
        }
    }

    else if (Type == NT::CUT_SERIALSAVE && !SP_usbportBut->text().isEmpty() && !SP_usbPortMenu->isEmpty())
    {
        if (serialInfoMap["sp_name"].contains(portName))
        {
            QRegularExpression reg("\\((\\d+)\\)");
            QStringList matchResult = reg.match(portName).capturedTexts();
            if (!matchResult.isEmpty())
            {   //#原副累积数增加1
                QString addString = QString::number(std::stoi(matchResult.last().toStdString().data()) + 1);
                QString splString = matchResult.first().replace(QRegularExpression("\\d+"), addString);
                portName = portName.replace(matchResult.first(), splString);
            }
            else
            {
                QStringList similarList = serialInfoMap["sp_name"].filter(portName);
                if (similarList.size() == 1)
                {
                    portName = portName + " (1)";
                }
                else
                {
                    QList<qint64> sqladdList;
                    foreach(QString NikeName, similarList){
                        QStringList matchResultT = reg.match(NikeName).capturedTexts();
                        if (!matchResultT.isEmpty())
                        {
                            sqladdList.append(std::stoi(matchResultT.last().toStdString().data()));
                        }
                    }
                    //#最大副累积数增加1
                    portName = portName + QString(" (%1)").arg(definfc.Max(sqladdList) + 1);
                }
            }
            diary("port Name is successfully modified: " + portName, Diary::Debug)
        }
        QStringList keys = {"sp_name", "apply"};
        QStringList values = {QString("'%1'").arg(portName), QString::number(false)};
        foreach(QString key, serialKeyList)
        {
            keys.append(impact_str[key].split("=").first().simplified());
            values.append(impact_str[key].split("=").last().simplified());
        }
        serialConnectSql = QString("INSERT INTO serial(%1)"
                                   "VALUES(%2)").arg(keys.join(","), values.join(","));
    }

    else if (Type == NT::CUT_SERIALCONNECT)
    {

        if (SP_sralPort->isOpen())
        {
            SP_sralPort->close();
        }
        else
        {
            if (SP_sralPort->open(QIODevice::ReadWrite))
            {
                diary("serial connect successful", Diary::Info)
                if (!impact_stchar["portname"].contains(impact_str["SerialPortName"]))
                {
                    diary("serial connect successful and portname is a free connect", Diary::Warning)
                }
                else
                {
                    if (!impact_str[RPLKEY.UPD_CNLIST_ITEMS].isEmpty())
                    {
                        QString NikeName = impact_stchar["sp_name"][impact_int["serialSqlIndex"]];
                        if (!NikeName.isEmpty())
                        {
                            Query->exec(QString("UPDATE serial SET apply=%1 WHERE sp_name!='%2'").arg(
                                        QString::number(false), NikeName));
                            Query->exec(QString("UPDATE serial SET apply=%1 WHERE sp_name='%2'").arg(
                                        QString::number(true), NikeName));
                            diary(QString("serial connect successful where nikename [%1]").arg(NikeName), Diary::Debug)
                        }
                    }
                }
            }

            else
            {
                diary("serial connect fail", Diary::Error)
            }
        }
    }

    if (Type != NT::CUT_SERIALCONNECT)
    {
        if (Query->exec(serialConnectSql) && impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
        {
            data_serial_Infoquery();
            data_reserve_loader(NT::CUT_CONNECTLIST);
            diary("connect data list update now ", Diary::Debug)
        }
    }
    if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
    {
        if (SP_sralPort->isOpen())
        {
            DT_exec->doconfigur_text("关闭串口");
        }
        else
        {
            DT_exec->doconfigur_text("打开串口");
        }
    }
}

//# Command Data Send / Command Save
void ToolLogicCT::data_serial_commandbranch(NT::TOOL_VALIDCUT Type, QString command){ //*********************ERROR
    diary("skip this", Diary::Debug)
    if (Type == NT::CUT_COMMANDSEND)
    {
        QStringList commandCodeList;
        QString sourceCommand;
        command.isEmpty() ? sourceCommand = SP_commandEdit->toPlainText() : sourceCommand = command;
        commandCodeList = sourceCommand.split(QRegularExpression("\\&\\&|\\-\\>|\\s+\\+\\s+|\\s+\\=\\s+|/|\\\\"));
        SP_sralPort->clear();
        foreach(QString commandCode, commandCodeList)
        {
            if (!commandCode.simplified().isEmpty())
            {
                QStringList matchList = QRegularExpression(SP_taskTimer_Reboot).match(commandCode).capturedTexts();
                if (!matchList.isEmpty())
                {
                    QString numchar = matchList.last();
                    if (!matchList.isEmpty() && definfc.isInt(numchar))
                    {
                        impact_str["TaskForReboot"] = sourceCommand.remove(QRegularExpression(SP_taskTimer_Reboot));
                        SRLP_CMDLOOP_QTIER.setInterval(numchar.toUInt());
                        SRLP_CMDLOOP_QTIER.start();
                        SyntaxHLight->setTask(SP_taskMap);
                        impact_swtc["RebootTaskHint"] = false;
                        SP_serialInfoEdit->appendPlainText(QString("\n=====定时任务 %1 开始运行，重启间隔: %2\n=====").arg(impact_str["TaskForReboot"], numchar));
                    }
                }
                if (commandCode.contains(QRegularExpression(SP_taskTimer_RebootE)))
                {
                    data_task_runend(TIMER_TASK.SERIALFUNC_REBOOTIMER);
                }
                if (SP_sralPort->isOpen())
                {
                    QByteArray btcommandCode = commandCode.trimmed().toLocal8Bit();
                    if (SP_newlineCheckBox->isChecked()) btcommandCode.append("\r\n");
                    qint64 exec = SP_sralPort->write(btcommandCode);
                    if (exec >= 0)
                    {
                        SP_sralPort->flush();
                        SP_sralPort->waitForBytesWritten(10);
                    }
                }
            }
        }
    }

    else if (Type == NT::CUT_COMMANDSAVE)
    {
        if (impact_stchar["sp_name"].isEmpty())
        {
            diary("serial data is empty, command save is fail", Diary::Info)
        }
        else
        {
            QString commandCode = command.split(QRegularExpression("/|\\\\|->|~|&&|\n")).
                                          filter(QRegularExpression(".+")).join("&&");

            QString NikeName = impact_stchar["sp_name"][impact_int[RPLKEY.UPD_CNLIST_ROW]];
            QString auldConmandCode = impact_stchar["ordercode"][impact_int[RPLKEY.UPD_CNLIST_ROW]];
            //#AuldCommand Gather
            QStringList allcommandList = auldConmandCode.split("&&").filter(QRegularExpression("\\w+"));
            allcommandList.append(commandCode);
            allcommandList.removeDuplicates();

            //#ordernike Gather
            QStringList OrderNikeList;
            QStringList OrderNikeSqlList = impact_stchar["ordernike"];
            //#如果是命令列表，则刷新
            if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_COMMANDLIST)
            {
                int maxDataCount = BS_listWidget->count();
                for(int row=0; row < maxDataCount; row++)
                {
                   OrderNikeList.append(BS_listWidget->item(row)->text());
                }
                OrderNikeList.append(commandCode);
            }
            else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
            {
                OrderNikeList.append(allcommandList.join("&&"));
            }
            QString commandSaveSql = QString("UPDATE serial SET ordercode='%1', ordernike='%2' WHERE sp_name='%3'").
                                     arg(allcommandList.join("&&"), OrderNikeList.join("&&"), NikeName);
            Query->exec(commandSaveSql);
            data_serial_Infoquery();
            if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_COMMANDLIST)
            {
                data_reserve_loader(NT::CUT_COMMANDLIST);
            }
            diary("command save is successfully", Diary::Info)
        }
    }
}

//# TaskTimer Running End And Recycle Command Combine Running
void ToolLogicCT::data_task_runend(QString flag){
    diary("skip this", Diary::Debug)
    if (flag == TIMER_TASK.SERIALFUNC_REBOOTIMER)
    {
        SRLP_CMDLOOP_QTIER.stop();
        impact_int["TaskTimerCOunt"] = 0;
        if (!impact_swtc["RebootTaskHint"])
        {
            SP_serialInfoEdit->insertPlainText(QString("\n=====重启定时任务关闭=====\n"));
            impact_swtc["RebootTaskHint"] = true;
        }
    }
    else
    {
        data_serial_commandbranch(NT::CUT_COMMANDSEND, flag);
        impact_int["TaskTimerCOunt"] += 1;
    }
}

//# Command Import
void ToolLogicCT::data_serial_commandimport(){
    diary("skip this", Diary::Debug)
    QString clipData = Reader::g_clipb().c_str();
    data_serial_commandbranch(NT::CUT_COMMANDSAVE, clipData);
}

//# High Light Color Dia Config
void ToolLogicCT::data_serial_hlclrcfg(bool isForeColor){
    diary("skip this", Diary::Debug)
    connect(&colorDia, &QColorDialog::colorSelected, this, &ToolLogicCT::data_serial_hlclslct);
    colorDia.setVisible(true);
    colorDia.move(pos().x() + 165, pos().y());
    if (isForeColor)
    {
        impact_ttype[RPLKEY.UPD_COLOR_CHANGE] = NT::UPD_FORECOLOR;
    }
    else
    {
        impact_ttype[RPLKEY.UPD_COLOR_CHANGE] = NT::UPD_BACKCOLOR;
    }
}

//# Color selected
void ToolLogicCT::data_serial_hlclslct(const QColor &color){
    diary("skip this", Diary::Debug)
    QString red = QString::number(color.red());
    QString green = QString::number(color.green());
    QString blue = QString::number(color.blue());
    QString hintColor = QString("rgb(%1,%2,%3)").arg(red, green, blue);
    if (impact_ttype[RPLKEY.UPD_COLOR_CHANGE] == NT::UPD_FORECOLOR)
    {
        SP_hlfrclEdit->setText(hintColor);
    }

    else if (impact_ttype[RPLKEY.UPD_COLOR_CHANGE] == NT::UPD_BACKCOLOR)
    {
        SP_hlbkclEdit->setText(hintColor);
    }
}

//# HighLight Save / Update
void ToolLogicCT::data_serial_hlbranch(){
    diary("skip this", Diary::Debug)
    QString highLightText = SP_hltextEdit->text();
    QString NikeName = impact_stchar["sp_name"][impact_int[RPLKEY.UPD_CNLIST_ROW]];
    QString hlSqlText = impact_stchar["highlight"][impact_int[RPLKEY.UPD_CNLIST_ROW]];
    QStringList sqlHlist;
    QStringList highLightSqlList = hlSqlText.split("&&");
    foreach(QString hlText, highLightSqlList) sqlHlist.append(hlText.split("->").first());
    bool sqlEmpty = false;
    bool isUpdate =false;
    int indexof = 0;
    (!sqlHlist.contains(highLightText)) ? sqlEmpty = true : indexof = sqlHlist.indexOf(highLightText);
    if (!highLightText.isEmpty())
    {
        QList<QVariant> backColorList = data_serial_hlclparser(SP_hlbkclEdit->text(), ",", "|");
        QString backColor = backColorList.first().toString(); //#获取深度为0的色素字符串
        if (!SP_hlbkclEdit->text().isEmpty())
        {
            QList<QVariant> foreColorList = data_serial_hlclparser(SP_hlfrclEdit->text(), ",", "|");
            QString foreColor = foreColorList.first().toString(); //#获取深度为0的色素字符串
            QList<QString> colorSec({highLightText, backColor, foreColor});
            if (sqlEmpty)
            {
                if (hlSqlText.isEmpty()) highLightSqlList.removeAt(0);
                highLightSqlList.append(colorSec.join("->"));
                isUpdate = true;
                diary("the data is not exists in the database", Diary::Debug)
            }
            else //#否则提取对应数据，将背景色信息更新至数据中
            {
                highLightSqlList[indexof] = colorSec.join("->");
                isUpdate = true;
                diary("the data is exists in the database", Diary::Debug)
            }

            if (isUpdate) //#如果以上代码成功执行了，则开始导入数据库
            {
                QString highLightSaveSql = QString("UPDATE serial SET highlight='%1' WHERE sp_name='%2'").arg(
                                           highLightSqlList.join("&&"),
                                           NikeName);

                if (Query->exec(highLightSaveSql))
                {
                    data_serial_Infoquery(); // 无论当前列表是否高亮列表，理应进行更新操作，否则数据更新将堵塞
                    if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_HLITEXTLIST)
                    {
                        data_reserve_loader(NT::CUT_HLITEXTLIST);
                    }
                    diary(QString("highlight update state: %1").arg(sqlEmpty), Diary::Debug)
                }
            }

            else
            {
                 new MessageBoxQ(this,
                                 {"知道了"},
                                 MessageBoxQ::MSG_Question,
                                 "提示信息",
                                 "缺失前景色信息");
            }
        }
        else
        {
            new MessageBoxQ(this,
                            {"知道了"},
                            MessageBoxQ::MSG_Question,
                            "提示信息",
                            "缺失背景色信息");
        }
    }
    else
    {
        new MessageBoxQ(this,
                        {"知道了"},
                        MessageBoxQ::MSG_Question,
                        "提示信息",
                        "请输入高亮文本");

    }
}

//# reHighLight Trigger Qustion
void ToolLogicCT::data_serial_hltriggered(){
    if (impact_int["HighLightType"] == NT::CUT_KEYWORKHL)
    {
        SRLP_HLDLTRIGG_QTIER.setInterval(30);
    }
    else
    {
        SRLP_HLDLTRIGG_QTIER.setInterval(1000);
    }
    if (!SRLP_HLDLTRIGG_QTIER.isActive()) SRLP_HLDLTRIGG_QTIER.start();
}

//# reHighLight Trigger
void ToolLogicCT::data_serial_hlcfgexec(){
    QTextBlock firstBlock = SP_serialInfoEdit->firstVisibleBlock();
    QTextBlock lastBlock = SP_docuMent->lastBlock();
    int blockHadd = 0;
    if (lastBlock.blockNumber())
    {
        for (int blockNum = firstBlock.blockNumber(); blockNum < lastBlock.blockNumber(); blockNum++)
        {
            QTextBlock followUpBlock = SP_docuMent->findBlockByNumber(blockNum);
            QRectF blockRectF = documentLayout->blockBoundingRect(followUpBlock);
            QRect viewportRect = SP_serialInfoEdit->viewport()->rect();
            if (blockHadd > viewportRect.height())
            {
                break;
            }
            else
            {
                if (impact_int["HighLightType"] == NT::CUT_GLOBALHL)
                {
                    SyntaxHLight->rehighlightBlock(followUpBlock);

                }
                else
                {
                    if (followUpBlock == SP_serialInfoEdit->textCursor().block()) MatchKeyWord->setSpecialEcho(true);
                    MatchKeyWord->rehighlightBlock(followUpBlock);
                    MatchKeyWord->setSpecialEcho(false);
                }
            }
            blockHadd += blockRectF.height();
        }
        if (SRLP_HLDLTRIGG_QTIER.isActive()) SRLP_HLDLTRIGG_QTIER.stop();
    }
}

//# highLight String Color Paerser
QList<QVariant> ToolLogicCT::data_serial_hlclparser(QString color, QString replaceStr, QString swapStr, uint depth){
    QList<QVariant> Variantlist;
    QRegularExpression colorReg("[\\d+\\,|\\|]+");
    QRegularExpressionMatch matchColor = colorReg.match(color);
    QStringList colorCapTexts = matchColor.capturedTexts();
    QString red;
    QString green;
    QString blue;
    if (!colorCapTexts.isEmpty())
    {
        if (matchColor.hasMatch())
        {
            //#获取提取到的Color字符串，按特殊字符分割，得到红绿蓝色素
            QString colorChar = colorCapTexts.last();
            QStringList colorSplitList = colorChar.split(QRegularExpression("\\W+"));
            if (depth == 0) //#深度0，获取色素字符串，深度1，获取色素点
            {
                //# 如果不需要替换字符，直接添加
                if (replaceStr.isEmpty() && swapStr.isEmpty())
                {
                    Variantlist.append(colorChar);
                }
                else
                {
                    Variantlist.append(colorChar.replace(replaceStr, swapStr));
                }
            }
            else if (!colorSplitList.isEmpty() && colorSplitList.count() >= 3 && depth == 1)
            {
                red = colorSplitList[0];
                green = colorSplitList[1];
                blue = colorSplitList[2];
                Variantlist.append(red.toUInt());
                Variantlist.append(green.toUInt());
                Variantlist.append(blue.toUInt());
            }
        }
    }
    return Variantlist;
}

//# Search
void ToolLogicCT::data_serial_kwfind(){
    QString kchar = SP_ksearchEdit->text();
    if (!kchar.isEmpty())
    {
        impact_int["HighLightType"] = NT::CUT_KEYWORKHL;
        MatchKeyWord->findX(kchar);
        SP_serialInfoEdit->setBreakAwayFromFollow(false);
        data_serial_hltriggered();
    }

}

//# Search OPtion
void ToolLogicCT::data_serial_kwoption(int Type, int state){
    diary("skip this", Diary::Debug)
    if (state == 0)
    {
        if (!Type)
        {
            MatchKeyWord->setFindBackward(false);
        }
        else
        {
            MatchKeyWord->setCaseSensitive(false);
        }
    }
    else if (state == 2)
    {
        if (!Type)
        {
            MatchKeyWord->setFindBackward(true);
        }
        else
        {
            MatchKeyWord->setCaseSensitive(true);
        }
    }
}

//# Exit Search High Light Config
void ToolLogicCT::data_serial_hlrecover(QString searchText){
    diary("skip this", Diary::Debug)
    if (searchText.isEmpty())
    {
        diary("search edit content is empty, exit highlight mode", Diary::Debug)
        impact_int["HighLightType"] = NT::CUT_GLOBALHL;
        MatchKeyWord->clearSpecialFormat();
        SP_serialInfoEdit->setBreakAwayFromFollow(true);
        data_reserve_loader(NT::CUT_HLITEXTLIST, false);
    }
}

//# Exit Search High Light Config
void ToolLogicCT::data_serial_hlrecover(int index){
    if (SP_TabWidget->widget(index)->objectName() != SP_ksearchWidget->objectName() &&
        impact_int["HighLightType"] == NT::CUT_KEYWORKHL)
    {
        diary("stackwidget index change, exit highlight mode", Diary::Debug)
        impact_int["HighLightType"] = NT::CUT_GLOBALHL;
        MatchKeyWord->clearSpecialFormat();
        SP_serialInfoEdit->setBreakAwayFromFollow(true);
        data_reserve_loader(NT::CUT_HLITEXTLIST, false);

    }
}

//# Query List Data Of Serial
void ToolLogicCT::data_serial_Infoquery(){
    diary("skip this", Diary::Debug)
    QMap<QString, QList<QString>> serialInfoMap = definfc.SuperQuery(DATABASE, "serial");
    serialInfoMap.swap(impact_stchar); //# 不能放入非空条件下执行，因为会造成全部删除后但始终有数据的情况
    if (!serialInfoMap.isEmpty())
    {
        diary("map swap finish", Diary::Debug)
    }
    else
    {
        diary("map swap fail because info is empty", Diary::Error)
    }
}

//# Query List Data Of Qrcode
void ToolLogicCT::data_qrcode_Infoquery(){
    diary("skip this", Diary::Debug)
    QMap<QString, QList<QString>> qrcodeInfoMap = definfc.SuperQuery(DATABASE, "qrcode");
    impact_stchar.swap(qrcodeInfoMap); //# 不能放入非空条件下执行，因为会造成全部删除后但始终有数据的情况
    if (!qrcodeInfoMap.isEmpty())
    {
        diary("map swap finish", Diary::Debug)
    }
    else
    {
        diary("map swap fail because info is empty", Diary::Error)
    }
}

//# Qrcode Data Update / Save / Product
void ToolLogicCT::data_qrcodebranch(NT::TOOL_VALIDCUT Type, bool isUpdate){
    diary(QString("skip thisType: %1").arg(Type), Diary::Debug)
    QString qrcodeData = QR_dataEdit->toPlainText();
    QString qrcodeKey = QR_keysEdit->toPlainText();
    QString qrAliasText = QR_aliasEdit->toPlainText();
    QString rplProductData = QR_dataEdit->toPlainText();
    QString imageName;
    if (qrAliasText.isEmpty())
    {
        definfc.getMatchingItem({"http[s]?\\s*:\\s*[\\\\/](.{5,}?)[\\\\/]", "\\d+[\\-_+&\\]\\[\\.,]+\\d+"}, rplProductData, imageName, {1, -1});
        imageName = imageName.remove(QRegularExpression("http[s]?\\W*|www\\W*")).
                              remove(":").
                              remove(QRegularExpression("[\\\\/]")).
                              replace(QRegularExpression("\\W+com"), " ");
    }
    else
    {
        imageName = qrAliasText;
    }
    QString savePath = impact_str["QRcodePath"] + "/" + imageName + ".png";
    QString qrcodePath = Nlwingsing::jigsawPath(savePath);
    if (!QR_saveQrBox->isChecked()) qrcodePath.clear();
    if (Type == NT::CUT_QRCODESAVE)
    {
        QString QRcodeSql=NULL;
        QString qrcodeAlias=NULL;
        qrAliasText.isEmpty() ? qrcodeAlias = qrcodeData : qrcodeAlias = qrAliasText;
        if (impact_stchar["data"].contains(qrcodeData))
        {
            uint indexof = impact_stchar["data"].indexOf(qrcodeData);
            //# 剔除原别名，与其他别名数据不重复即可
            QStringList consultAliasList = impact_stchar["alias"];
            QString qrcodeSqlID = impact_stchar["id"][indexof];
            consultAliasList.removeAt(indexof);
            if (!consultAliasList.contains(qrAliasText))
            {
                QRcodeSql = QString("UPDATE qrcode SET data='%1', key='%2', alias='%3', route='%4' WHERE id=%5").arg(
                            qrcodeData,
                            qrcodeKey,
                            qrcodeAlias,
                            qrcodePath,
                            qrcodeSqlID);
                data_qrcodebranch(NT::CUT_QRCODEPROD);
                diary(QString("qrcode update prepare, id: %1").arg(qrcodeSqlID), Diary::Debug)
            }
            else
            {
                new MessageBoxQ(this,
                                {"知道了"},
                                MessageBoxQ::MSG_Question,
                                "Question",
                                "别名不可重复");
            }
        }
        else
        {
            if (!impact_stchar["Alias"].contains(qrAliasText))
            {
                QRcodeSql = QString("INSERT INTO qrcode(data,key,alias,route) VALUES('%1','%2','%3','%4');").arg(
                            qrcodeData,
                            qrcodeKey,
                            qrcodeAlias,
                            qrcodePath);
                diary("qrcode save prepare", Diary::Debug)
            }

            else
            {
                //# 默认值为 true， 即提示为必触发状态，除非别名为列表编辑状态，且不包含于数据库
                bool isDuplicates = true;
                if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_FROMQREDIT)
                {
                    int indexOf = impact_stint[RPLKEY.UPD_HLLIST_ROWS].last();
                    QString currentItemText = BS_listWidget->item(indexOf)->text();
                    if (!impact_stchar["Alias"].contains(currentItemText))
                    {
                        isDuplicates = false;
                    }
                }
                if (isDuplicates)
                {
                    new MessageBoxQ(this,
                                    {"知道了"},
                                    MessageBoxQ::MSG_Question,
                                    "Question",
                                    "别名不可重复");
                }
            }
        }
        if (Query->exec(QRcodeSql))
        {
            if (isUpdate)
            {
                data_qrcode_Infoquery();
                data_reserve_loader(NT::CUT_QRCODELIST);
            }
            SRLP_DLRMV_QTIER.start();
            diary("qrcode save/update is successfully", Diary::Debug)
        }
        else
        {
            diary(QString("QRCODE save/update Error: %1").arg(Query->lastError().text()), Diary::Warning)
        }
    }

    else if (Type == NT::CUT_QRCODEPROD)
    {
        QString productData=NULL;
        if (QR_modeCutBox->isChecked())
        {
            if (qrcodeKey.isEmpty())
            {
                if (!qrcodeData.isEmpty()) productData = impact_str["QRformatE"].arg(qrcodeData);
            }
            else
            {

                if (!qrcodeData.isEmpty()) productData = impact_str["QRformatT"].arg(qrcodeData, qrcodeKey);
            }
        }

        else
        {
            if (!qrcodeData.isEmpty()) productData = qrcodeData;
        }

        if (!productData.isEmpty())
        {
            //#=====生产二维码失败原因，颜色字符串参数多了个逗号，导致颜色识别失败，生成的byte数据错乱，pixmap加载失败
            QPixmap qrPixmap;
            PPScriptExec::pyScript_QrcodeByte("outer_script",
                                              "qrcode_make",
                                              productData.toStdString().data(),
                                              qrPixmap,
                                              qrcodePath.toStdString().data(),
                                              impact_str["QRforeColor"].toStdString().data(),
                                              impact_str["QRbackColor"].toStdString().data(),
                                              impact_int["QRcodeBorderXP"],
                                              impact_int["QrcodeSizeRtXP"]);
            if (!qrPixmap.isNull()) QR_qrcodeLabel->setPixmap(qrPixmap);
            diary(QString("bkColor: %1, frColor: %2 path: %3").arg(impact_str["QRbackColor"],
                                                                           impact_str["QRforeColor"],
                                                                           qrcodePath), Diary::Debug)
        }
    }
}

//# Qrcode Format Extract
void ToolLogicCT::data_qrcode_formatbeautify(QString &_s){
    diary("skip this", Diary::Debug)
    uint replaceUcount = 1;
    QString beautifyChar;
    QStringList globalFormatList = Extend().getGlobalMatching(_s, "\\w+\\W{1}\\w+");
    foreach(QString format, globalFormatList)
    {
        bool isSpecailExists = format.contains(QRegularExpression("\\W"));
        if (isSpecailExists)
        {
            uint indexof = format.indexOf(QRegularExpression("\\W")) + 1; //#不包括特殊符号
            QString midChar = format.mid(indexof);
            beautifyChar.append(format.replace(indexof,
                                midChar.size(),
                                QString("%%1").arg(QString::number(replaceUcount))) + " ");
            replaceUcount++;
        } else continue;
    }
    _s.swap(beautifyChar);
}

//# List Selected DoubleClick Event==============public
void ToolLogicCT::data_listitem_dbclickev(qint64 index){
    diary("skip this", Diary::Debug)
    bool canEdit = false;
    if (QList<uint>({NT::CUT_SERIALTOOL, NT::CUT_QRCODETOOL}).contains(
        impact_ttype[RPLKEY.CUT_FUNCNAME]) &&
        impact_ttype[RPLKEY.CUT_FUNCNAME] != NT::CUT_HLITEXTLIST)
    {

        if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
        {
            impact_ttype.insert(RPLKEY.CUT_EXBUTCHANGE, NT::CUT_FROMCNEDIT);
            canEdit = true;
        }

        else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_COMMANDLIST)
        {
            impact_ttype.insert(RPLKEY.CUT_EXBUTCHANGE, NT::CUT_FROMODEDIT);
            canEdit = true;
        }

        else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_QRCODELIST)
        {
            impact_ttype.insert(RPLKEY.CUT_EXBUTCHANGE, NT::CUT_FROMQREDIT);
            canEdit = true;
        }
    }
    if (canEdit)
    {
        QListWidgetItem *editItem = BS_listWidget->item(index);
        editItem->setFlags(editItem->flags() | Qt::ItemIsEditable);
        DT_exec->doconfigur_text("编辑完成");
        BS_listWidget->setStyleSheet((*__QSSMAP__)["anl_lstwin"].arg(16));
        diary("CUT_EXBUTCHANGE Valuetion Finish", Diary::Debug)
    }
}

//# List Selected Selected Event==============public
void ToolLogicCT::data_listitem_slctev(){
    diary("skip this", Diary::Debug)
    QStringList selectedTextList;
    QList<qint64> selectedRowsList;
    QList<QListWidgetItem *> selectionItemList = BS_listWidget->selectedItems();
    if (!selectionItemList.isEmpty())
    {
        foreach(QListWidgetItem *item, selectionItemList)
        {
            selectedTextList.append(item->text());
            selectedRowsList.append(BS_listWidget->row(item));
        }
        if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_SERIALTOOL)
        {
            if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
            {
                impact_str[RPLKEY.UPD_CNLIST_ITEMS] = selectedTextList.join("&&");
                impact_stint[RPLKEY.UPD_CNLIST_ROWS] = selectedRowsList;
                impact_int[RPLKEY.UPD_CNLIST_ROW] = selectedRowsList.last();
                QString SQL_PortName = impact_stchar["sp_name"][impact_int[RPLKEY.UPD_CNLIST_ROW]];
                impact_str["inAdvanceCNitem"] = SQL_PortName;
                data_serial_summaryconfig(false, SQL_PortName);
                SPitem_viewWidget->setVisible(true);
                diary(impact_str[RPLKEY.UPD_CNLIST_ITEMS], Diary::Debug)
            }

            else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_COMMANDLIST)
            {
                QStringList commandList;
                impact_str[RPLKEY.UPD_ODLIST_ITEMS] = selectedTextList.join("&&");
                impact_stint[RPLKEY.UPD_ODLIST_ROWS] = selectedRowsList;
                impact_int[RPLKEY.UPD_ODLIST_ROW] = selectedRowsList.last();
                if (!impact_stchar["ordercode"].isEmpty())
                {
                    QStringList CommandCodeList = impact_stchar["ordercode"][impact_int[RPLKEY.UPD_CNLIST_ROW]].split("&&");
                    //#脏数据预防，当索引不超限时才获取对应命令码
                    if (impact_int[RPLKEY.UPD_ODLIST_ROW] <= CommandCodeList.size() - 1)
                    {
                        foreach(int row, selectedRowsList) commandList.append(CommandCodeList[row]);
                        SP_commandEdit->setPlainText(commandList.join("&&"));
                    }
                }
                diary(impact_str[RPLKEY.UPD_ODLIST_ITEMS], Diary::Debug)
            }

            else if (impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_HLITEXTLIST)
            {
                impact_stint[RPLKEY.UPD_HLLIST_ROWS] = selectedRowsList;
                int indexOf = impact_stint[RPLKEY.UPD_HLLIST_ROWS].last();
                if (!impact_stchar["highlight"].isEmpty())
                {
                    QStringList highLightList = impact_stchar["highlight"][impact_int[RPLKEY.UPD_CNLIST_ROW]].split("&&");
                    if (impact_stint[RPLKEY.UPD_HLLIST_ROWS].last() + 1 <= highLightList.size())
                    {
                        highLightList = impact_str[BS_listWidget->item(indexOf)->text().trimmed()].split("->");
                        if (!highLightList.isEmpty() && highLightList.count()>= 3)
                        {
                            QStringList bkColorList = highLightList[1].split("|");
                            QStringList frColorList = highLightList[2].split("|");
                            if (bkColorList.count() >= 3 &&
                                frColorList.count() >= 3)
                            {
                                SP_hltextEdit->setText(highLightList[0]);
                                SP_hlbkclEdit->setText(QString("rgb(%1,%2,%3)").arg(bkColorList[0], bkColorList[1], bkColorList[2]));
                                SP_hlfrclEdit->setText(QString("rgb(%1,%2,%3)").arg(frColorList[0], frColorList[1], frColorList[2]));
                            }
                            else
                            {
                                SP_hltextEdit->setText("数据错误");
                                SP_hlbkclEdit->clear();
                                SP_hlfrclEdit->clear();
                            }
                        }
                    }
                }
                diary(selectedTextList.join(" "), Diary::Debug)
            }
        }

        else if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_QRCODETOOL)
        {
            impact_stint[RPLKEY.UPD_QRLIST_ROWS] = selectedRowsList;
            int indexOf = impact_stint[RPLKEY.UPD_QRLIST_ROWS].last();
            QString qrcodeData = impact_stchar["data"][indexOf];
            QString qrcodeKey = impact_stchar["key"][indexOf];
            QString qrcodeAlias = impact_stchar["alias"][indexOf];
            QString qrcodePath = impact_stchar["route"][indexOf];
            QR_dataEdit->setPlainText(qrcodeData);
            QR_keysEdit->setPlainText(qrcodeKey);
            QR_aliasEdit->setPlainText(qrcodeAlias);

            if (!QFileInfo(qrcodePath).isFile())
            {
                QR_hintLabel->clear();
                QR_saveQrBox->setChecked(false);
            }
            else
            {
                QR_hintLabel->setText(qrcodePath);
                QR_saveQrBox->setChecked(true);
            }
            data_qrcodebranch(NT::CUT_QRCODEPROD, false);
        }
    }
}

//# Analysis Function
void ToolLogicCT::data_tool_execstart(int index){
    diary("skip this", Diary::Debug)
    QListWidgetItem *cur = BS_listWidget->item(index);
    if (cur)
    {
        QString indexChar = cur->text();
        if (indexChar == "文档数据比对")
        {
            if (CP_Widget->isVisible())
            {
                if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_SERIALTOOL)
                {
                    PBL_centraStackWidget->setCurrentWidget(SP_Widget);
                }

                else if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_ANALYTOOL)
                {
                    if (impact_str["MultiFaceObject"] == DT_scview->objectName())
                    {
                        PBL_centraStackWidget->setCurrentWidget(DT_scdtEdit);
                    }
                    else
                    {
                        PBL_centraStackWidget->setCurrentWidget(DT_rsdtEdit);
                    }
                }

                else if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_QRCODETOOL)
                {
                    PBL_centraStackWidget->setCurrentWidget(QR_Widget);
                }
            }

            else
            {
                PBL_centraStackWidget->setCurrentWidget(CP_Widget);
            }
        }
    }
}

//# Analysis Funtion Current Selection Execute Cancle
void ToolLogicCT::data_listitem_unslctev(){
    diary("skip this", Diary::Debug)
    if (impact_ttype[RPLKEY.CUT_FUNCNAME] == NT::CUT_SERIALTOOL &&
        impact_ttype[RPLKEY.CUT_EXBUTCHANGE] == NT::CUT_CONNECTLIST)
    {
        if (!impact_str[RPLKEY.UPD_CNLIST_ITEMS].isEmpty())
        {
            for(int row = 0; row < BS_listWidget->count(); row++)
            {
                BS_listWidget->item(row)->setSelected(false);
            }
            impact_str["inAdvanceCNitem"].clear();
        }
    }
}


void ToolLogicCT::data_assistbut_error(QString name){
    diary(QString("objectname %1 pixmap is null, that view will be hidden").arg(name), Diary::Error)
}
